package cn.t.converter.order;

import cn.t.core.converter.CoreDTOConverter;
import cn.t.dto.android.ReplenishmentQueryPageRequest;
import cn.t.dto.order.ReplenishmentDTO;
import cn.t.dto.order.ReplenishmentExceptionRequest;
import cn.t.dto.order.repenlement.ReplenishmentPageDTO;
import cn.t.dto.order.repenlement.ReplenishmentQueryRequest;
import cn.t.model.order.ExceptionLogDO;
import cn.t.model.order.ReplenishmentDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

/**
 * 补货订单表(Replenishment)dto转domain
 *
 * @author t
 * @since 2024-05-24 10:19:35
 */
@Mapper(componentModel = "spring")
public interface ReplenishmentDTOConverter extends CoreDTOConverter<ReplenishmentDTO, ReplenishmentDO> {
        @Mapping(target = "rsStatus", source = "status")
        ReplenishmentQueryRequest req2PageDTO(ReplenishmentQueryPageRequest replenishmentDO);
        @Mapping(target = "rsUserName", source = "userName")
        ReplenishmentPageDTO toPageDTO(ReplenishmentDO replenishmentDO);
        @Mapping(target = "businessType", expression = "java(cn.t.enums.OptionTypeEnum.rs_open.getCode())"
        )
        @Mapping(target = "gmtCreatedStart", expression = "java(cn.t.utils.DateUtil.startDate(request.getGmtStart()))")
        @Mapping(target = "gmtCreatedEnd", expression = "java(cn.t.utils.DateUtil.endDate(request.getGmtEnd()))")
        @Mapping(target = "userName", source = "rsName")
        @Mapping(target = "orderSn", source = "rsSn")
        ExceptionLogDO requestToExceptionLogDO(ReplenishmentExceptionRequest request);
}

